-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
show_title #5
base: main
Are you sure you want to change the base?
show_title #5
Conversation
added "show_title" function for player
Added reset_title/clear_title
Added show_title, clear_title, reset_title
fixed show_title
fixed show_title
fixed color at show_title
fixed color at show_title
fixed show_title
fixed show_title
fixed import
fixed time
fixed time
fixed show_title
fixed show_title
fixed show_title
fixed show_title
fixed color at show_title
fixed color at show_title
fixed color at show_title
fixed port
Improved Color at show_title
Improved Color at show_title
Added slots to _types.py
Removed slots
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code funktioniert insofern ich das testen konnte, es gibt einige Typ-Unstimmigkeiten und Details, die mit Projektstruktur zu tun haben, ansonsten ein sehr guter erster Commit.
Ich würde den Commit akzeptieren, wenn die angemerkten Änderungen durchgeführt werden. Gute Arbeit!
mcproto/minecraft.py
Outdated
@@ -54,3 +55,13 @@ def port(self) -> int: | |||
def postToChat(self, *args, sep: str = " ") -> None: | |||
response = self._stub.postToChat(pb.ChatPostRequest(message=sep.join(map(str, args)))) | |||
raise_on_error(response) | |||
|
|||
def show_title(self, text: str, typ: Literal["actionbar", "subtitle", "title"] = "title", color: COLOR = "gray", bold: bool = "false", italic: bool = "false", strikethrough: bool = "false", underlined: bool = "false", obfuscated: bool = "false", duration: int = 1, fade_in: int = 5, fade_out: int = 1) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bitte gleiche Schreibweise von Funktionen weiterverwenden, wie im Projekt. Alle anderen Funktionen verwenden camelCase nicht snake_case.
Hier gibt es Typ-Unstimmigkeiten:
Du sagst zwar dass die Variablen bold, italic, usw. "bool" sind, sie sind aber "str" hier. Bitte auf echte "bool" ändern und falls Groß-Kleinschreibung im Befehl eine Rolle spielt, mit "str(True/False).lower()" umwandeln.
Zuletzt wäre ein Vorschlag die Duration auf 5 und den FadeIn auf 1 zu setzten.
mcproto/minecraft.py
Outdated
HasStub.runCommand(self, f'title @a times {fade_in}s {duration}s {fade_out}s') | ||
HasStub.runCommand(self, f'title @a {typ} ' + '{' + f'"text":"{text}","color":"{color}","bold":{bold},"italic":{italic},"strikethrough":{strikethrough},"underlined":{underlined},"obfuscated":{obfuscated}' + '}') | ||
|
||
def reset_title(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wozu brauchen wir resetTitle? Wird nicht eh jedes Mal, wenn wir showTitle aufrufen, die Attribute neu gesetzt?
mcproto/minecraft.py
Outdated
HasStub.runCommand(self, f'title @a reset') | ||
|
||
def clear_title(self): | ||
HasStub.runCommand(self, f'title @a clear') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Braucht kein f-string sein.
mcproto/player.py
Outdated
@@ -118,6 +119,16 @@ def op(self) -> None: | |||
def deop(self) -> None: | |||
HasStub.runCommand(self, f"deop {self.name}") | |||
|
|||
def show_title(self, text: str, typ: Literal["actionbar", "subtitle", "title"] = "title", color: COLOR = "gray", bold: bool = "false", italic: bool = "false", strikethrough: bool = "false", underlined: bool = "false", obfuscated: bool = "false", duration: int = 1, fade_in: int = 5, fade_out: int = 1) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bitte gleiche Änderungen wie oben für die Typen und den Case.
@@ -118,6 +119,16 @@ def op(self) -> None: | |||
def deop(self) -> None: | |||
HasStub.runCommand(self, f"deop {self.name}") | |||
|
|||
def show_title(self, text: str, typ: Literal["actionbar", "subtitle", "title"] = "title", color: COLOR = "gray", bold: bool = "false", italic: bool = "false", strikethrough: bool = "false", underlined: bool = "false", obfuscated: bool = "false", duration: int = 1, fade_in: int = 5, fade_out: int = 1) -> None: | |||
HasStub.runCommand(self, f'title {self.name} times {fade_in}s {duration}s {fade_out}s') | |||
HasStub.runCommand(self, f'title {self.name} {typ} ' + '{' + f'"text":"{text}","color":"{color}","bold":{bold},"italic":{italic},"strikethrough":{strikethrough},"underlined":{underlined},"obfuscated":{obfuscated}' + '}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Da wir in der Klasse Player > Entity hier sind, können wir ruhig die überschriebene "runCommand" Funktion dieser Klasse verwenden. Hier direkt HasStub.runCommand zu verwenden umgeht die Klassenhierachie.
Wenn man das macht, könnte man auch bei allen Befehlen einfach 'title @s ...' schreiben, da der Player identifier schon in Entity.runCommand gesetzt wird 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bitte diesen Punkt noch ausbessern, alle Instanzen von HasStub.runCommand
durch self.runCommand
ersetzten, und im Falle von der Player-Klasse, mit title @s ...
anstelle von title {self.name} ...
- Used camelCase - Removed reset_title - Change default values - Imported Literal
- Used camelCase - Removed reset_title - Change default values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Danke fürs ausbessern soweit. Bitte noch die zwei letzten Kommentare zu 1) Datentypen und 2) HasStub -> self ersetzten, dann sind alle Punkte erledigt 👍
@@ -118,6 +119,16 @@ def op(self) -> None: | |||
def deop(self) -> None: | |||
HasStub.runCommand(self, f"deop {self.name}") | |||
|
|||
def show_title(self, text: str, typ: Literal["actionbar", "subtitle", "title"] = "title", color: COLOR = "gray", bold: bool = "false", italic: bool = "false", strikethrough: bool = "false", underlined: bool = "false", obfuscated: bool = "false", duration: int = 1, fade_in: int = 5, fade_out: int = 1) -> None: | |||
HasStub.runCommand(self, f'title {self.name} times {fade_in}s {duration}s {fade_out}s') | |||
HasStub.runCommand(self, f'title {self.name} {typ} ' + '{' + f'"text":"{text}","color":"{color}","bold":{bold},"italic":{italic},"strikethrough":{strikethrough},"underlined":{underlined},"obfuscated":{obfuscated}' + '}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bitte diesen Punkt noch ausbessern, alle Instanzen von HasStub.runCommand
durch self.runCommand
ersetzten, und im Falle von der Player-Klasse, mit title @s ...
anstelle von title {self.name} ...
@@ -54,3 +56,10 @@ def port(self) -> int: | |||
def postToChat(self, *args, sep: str = " ") -> None: | |||
response = self._stub.postToChat(pb.ChatPostRequest(message=sep.join(map(str, args)))) | |||
raise_on_error(response) | |||
|
|||
def showTitle(self, text: str, typ: Literal["actionbar", "subtitle", "title"] = "title", color: COLOR = "gray", bold: bool = "false", italic: bool = "false", strikethrough: bool = "false", underlined: bool = "false", obfuscated: bool = "false", duration: int = 3, fade_in: int = 1, fade_out: int = 1) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Und zuletzt bitte noch die Datentypen anpassen: Datentyp bool
sollte als default Argument True oder False haben, nicht "true" oder "false". 👍
Übrigens, es gibt noch einen Punkt der wichtig für mich ist: und zwar, gibt es ein default formatting in diesem Projekt, das mit Auf diese Art und Weise ist alles einheitlich und sortiert. |
Added show_title function